package com.demo.sayhelloworld.say;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.CommandLineRunner;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import java.net.URI;
import java.net.URISyntaxException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;

@RefreshScope
@RestController
public class SayDemo {

    @Value("${say.text}")
    private String text;

    @Autowired
    private Entity entity;


    @RequestMapping("/t")
    public String testRefresh(){

        fun();
        return "config配置中心输出say.text= "+text;
    }

    private void fun(){

        System.out.println("config配置中心输出say.text= " + text);
        System.out.println("config配置中心输出mybean.*= " + entity);
        System.out.println("---------------end---------------" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));

    }
}
